r[7<<14];
c(int*a,int*b){return *a-*b;}
main(i,n)
{
	for(scanf("%d",&n),i=0;i<n;scanf("%d",r+i++));
	for(scanf("%d",&i);~scanf("%d",&i);printf("%d\n",i<0?-1:i))
		i=bsearch(&i,r,n,4,c),i-=(int)r,i/=4;
}
